﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace exsportance.Silverlight.Common.Helper
{
    public abstract class TransitionBase
    {
        public event EventHandler<TransitionCompletedEventArgs> TransitionCompleted;

        protected void OnTransitionCompleted(UserControl newPage, UserControl oldPage)
        {
            if (TransitionCompleted != null)
                TransitionCompleted(this, new TransitionCompletedEventArgs() { NewPage = newPage, OldPage = oldPage });

            if (oldPage is IDisposable)
                (oldPage as IDisposable).Dispose();

            oldPage = null;
        }

        public abstract void PerformTranstition(UserControl newPage, UserControl oldPage);
    }

    public class TransitionCompletedEventArgs : EventArgs
    {
        public UserControl NewPage { get; set; }
        public UserControl OldPage { get; set; }
    }
}
